package com.tongtech.space.common.utils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;


/**
 * 配置读取工具类
 * Todo 考虑优化
 *
 * @author jinjiayu
 * @since 2020/12/14
 */
@Component
public class PropertyUtil {
	@Autowired
	private Environment env;
	
	private static Environment props;
	
	@PostConstruct
	public synchronized void init() {
		props = env;
	}
	
    public static String getProperty(String key){
        return props.getProperty(key);
    }

    public static String getProperty(String key, String defaultValue) {
        return props.getProperty(key, defaultValue);
    }



}
